<script lang="ts" setup>
import { reactive } from 'vue'
import { useRouter } from 'vue-router'

const router = useRouter()

interface LoginForm {
  username: string
  password: string
}

const loginForm = reactive<LoginForm>({
  username: '',
  password: ''
})

const handleLogin = async () => {
  try {
    // TODO: 实现登录逻辑
    console.log('登录信息:', loginForm)
    router.push('/policePage')
  } catch (error) {
    console.error('登录失败:', error)
  }
}
</script>

<template>
  <div class="wrapper">
    <img style="width: 200px;height: 200px;"  src="@/assets/imgs/police.png" alt="">
    <div class="login-container">
      <div class="login-box">
        <h2>警务人员登录</h2>
        <form @submit.prevent="handleLogin">
          <div class="input-group">
            <input
                type="text"
                v-model="loginForm.username"
                placeholder="请输入账号"
                required
            >
          </div>
          <div class="input-group">
            <input
                type="password"
                v-model="loginForm.password"
                placeholder="请输入密码"
                required
            >
          </div>
          <button type="submit">登录</button>
        </form>
      </div>
    </div>
  </div>
</template>

<style scoped>
.wrapper {
  width: 100%;
  height: 100vh;
  background-color: #1e90ff;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 40px;
}

.login-container {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  flex: 1;
  margin-top: -20px;
}

.login-box {
  width: 400px;
  padding: 40px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

h2 {
  text-align: center;
  margin-bottom: 30px;
  color: #333;
}

.input-group {
  margin-bottom: 20px;
}

input {
  width: 100%;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 16px;
  outline: none;
}

input:focus {
  border-color: #1e90ff;
}

button {
  width: 100%;
  padding: 12px;
  background: #1e90ff;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.3s;
}

button:hover {
  background: #187bcd;
}
</style>


